package com.woniuxy.microcontentserver.sectionmsg.service.impl;

import com.woniuxy.microcontentserver.bean.SectionBean;
import com.woniuxy.microcontentserver.sectionmsg.mapper.SectionMapper;
import com.woniuxy.microcontentserver.sectionmsg.service.ISectioinService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;


@Transactional(readOnly = true)
@Service
public class SectionServiceImpl implements ISectioinService {

    @Resource
    private SectionMapper sectionMapper;

    /**
     * 查询所有栏目
     * @param sectionBean
     * @return
     */
    @Override
    public List<SectionBean> findAll(SectionBean sectionBean) {
        return sectionMapper.findAll(sectionBean);
    }

    @Override
    public SectionBean getOneById(Long id) {
        return sectionMapper.getOneById(id);
    }

    /**
     * 添加栏目
     * @param sectionBean
     * @return
     */
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor =Exception.class)

    @Override
    public int addSectionBean(SectionBean sectionBean) {
        return sectionMapper.addSectionBean(sectionBean);
    }

    /**
     * 修改栏目
     * @param sectionBean
     * @return
     */
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public int updateSectionBean(SectionBean sectionBean) {
        return sectionMapper.updateSectionBean(sectionBean);
    }



    /**
     * 删除栏目
     * @param id
     * @return
     */
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public int deleteSectoinBean(Long id) {

        return sectionMapper.deleteSectoinBean(id);
    }
}
